﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using digiTwitter.ExtensionMethods;
using System.Xml;

namespace digiTwitter
{
    public class TwitterSearchResult
    {
        public DateTime Published { get; set; }
        public String Title { get; set; }
        public String Content { get; set; }
        public String AuthorName { get; set; }
        public String AuthorUri { get; set; }

        /// <summary>
        /// Default constructor.
        /// </summary>
        public TwitterSearchResult()
        {
        }

         /// <summary>
        /// Overload constructor based on a XmlDocument.
        /// </summary>
        /// <param name="doc"></param>
        public TwitterSearchResult(XmlNode entryNode)
         {
             if (entryNode != null)
             {
                 Published = DateTime.Parse(entryNode.ChildNodes[1].InnerText);
                 Title = entryNode.ChildNodes[3].InnerText;
                 Content = entryNode.ChildNodes[4].InnerText;

                 XmlNode authorNode = entryNode.ChildNodes[10];
                  if (authorNode != null)
                  {
                      AuthorName = authorNode.ChildNodes[0].InnerText;
                      AuthorUri = authorNode.ChildNodes[1].InnerText;
                  }
             }
         }
    }
}
